import { useInterval } from 'ahooks';
import { useState } from 'react';
import { getCurrentDateTimeWeek } from 'web-plugin-utils';

interface DateTimeWeekState {
  currentDate: string;
  currentTime: string;
  currentWeek: string;
}

const initState: DateTimeWeekState = {
  currentDate: '',
  currentTime: '',
  currentWeek: '',
};

export default () => {
  const [dateTimeWeekState, setDateTimeWeekState] =
    useState<DateTimeWeekState>(initState);

  useInterval(() => {
    setDateTimeWeekState(getCurrentDateTimeWeek());
  }, 1000);

  return {
    ...dateTimeWeekState,
  };
};
